package Text23;

import java.util.*;

public class Main {
    public static int N = 110;
    public static int[][] v = new int[N][N];
    public static int[][] w = new int[N][N];
    public static int[] s = new int[N];
    public static int[] f = new int[N];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            s[i] = scanner.nextInt();
            for (int k = 1; k <= s[i]; k++) {
                v[i][k]=scanner.nextInt();
                w[i][k]=scanner.nextInt();
            }
        }
        for (int i = 1; i <=n ; i++) {
            for (int j = m; j>=1 ; j--) {
                for (int k = 0; k <= s[i]; k++) {
                    if(j>=v[i][k]){
                        f[j]=Math.max(f[j],f[j-v[i][k]]+w[i][k]);
                    }
                }
            }
        }
        System.out.println(f[m]);
    }
}
